import { IterableCollection, Iterator } from "./Interface";
import { User } from "./User";
import { UserIterator } from "./UserIterator";

// 有一个用户的集合
export class UserCollection implements IterableCollection<User> {
  private friends: User[]; // 用于存储好友的数组

  constructor() {
    this.friends = [];
  }

  addFriend(user: User) {
    this.friends.push(user);
  }

  createIterator(): Iterator<User> {
    return new UserIterator(this.friends);
  }
}
